﻿<Window x:Class="Probel.Ldoc.Views.ToolBoxes.MacroEditorView"
        
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:t="clr-namespace:Probel.Ldoc.Views.Properties"      
        xmlns:ae="http://icsharpcode.net/sharpdevelop/avalonedit"
        xmlns:conv="clr-namespace:Probel.Ldoc.Views.Converters"
        xmlns:s="clr-namespace:Probel.Ldoc.Views.Helpers"
                
        ShowInTaskbar="False" 
        WindowStartupLocation="CenterOwner" 
        WindowStyle="SingleBorderWindow" 
        Width="1024"
        Height="768"
        Title="{x:Static t:Messages.Title_ScriptEditor}" Icon="/Probel.Ldoc.Views;component/Images/Icon.ico">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Themes/Generic.xaml"/>
                <ResourceDictionary>
                    <conv:TextToDocumentConverter x:Key="TextToDocument"/>
                    <conv:InvertNullToBoolConverter x:Key="InvertNullToBool"/>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Window.Background>
        <ImageBrush ImageSource="/Probel.Ldoc.Views;component/Images/background.PNG" 
					Viewport="0,0,24,24"
					Stretch="None"
                    ViewportUnits="Absolute"   
					TileMode="Tile"/>
    </Window.Background>
    <Grid Background="{x:Null}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <HeaderedContentControl Header="{x:Static t:Messages.Header_Macro}">
            <DockPanel>
                <DockPanel DockPanel.Dock="Top"
                       LastChildFill="False"
                       Background="{x:Null}">
                </DockPanel>
                <ListBox ItemsSource="{Binding Macros}"
                         DisplayMemberPath="Title"
                         SelectedItem="{Binding CurrentMacro}"/>
            </DockPanel>
        </HeaderedContentControl>
        <HeaderedContentControl Header="{x:Static t:Messages.Header_ScriptEditor}" 
                                Grid.Column="1">
            <DockPanel>
                <ToolBarTray DockPanel.Dock="Top">
                    <ToolBar>
                        <Button DockPanel.Dock="Right"
                                Background="{x:Null}"
                                ToolTip="{x:Static t:Messages.Btn_AddScript}"
                                Command="{Binding AddNewMacroCommand}">
                            <Image Source="/Probel.Ldoc.Views;component/Images/File/New_File.png"
                                   Height="16"
                                   Width="16"/>
                        </Button>
                        <Button DockPanel.Dock="Right"
                                Background="{x:Null}"
                                ToolTip="{x:Static t:Messages.Action_Save}"
                                Command="{Binding SaveMacroCommand}">
                            <Image Source="/Probel.Ldoc.Views;component/Images/Save.png"
                           Height="16"
                           Width="16"/>
                        </Button>
                        <Button DockPanel.Dock="Right"
                        Background="{x:Null}"
                        ToolTip="{x:Static t:Messages.Btn_RemoveScript}"
                        Command="{Binding RemoveMacroCommand}">
                            <Image Source="/Probel.Ldoc.Views;component/Images/Delete.ico"
                               Height="16"
                               Width="16"/>
                        </Button>
                    </ToolBar>
                </ToolBarTray>
                <DockPanel DockPanel.Dock="Top"
                           LastChildFill="True">
                    <Label DockPanel.Dock="Left" 
                           Content="{x:Static t:Messages.Lbl_Title}"/>
                    <TextBox x:Name="titleBox" 
                             DockPanel.Dock="Right" 
                             Margin="5"                                 
                             Text="{Binding CurrentMacro.Title,UpdateSourceTrigger=PropertyChanged}"/>
                </DockPanel>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <GroupBox Header="{x:Static t:Messages.Header_Script}">
                        <ae:TextEditor x:Name="editor"
                                       IsEnabled="{Binding ElementName=editor, Path=Document, Converter={StaticResource InvertNullToBool}}"
                                       SyntaxHighlighting="Macro Highlighting"
                                       FontFamily="{s:SettingsBinding EditorFontFamily}" 
                                       FontSize="{s:SettingsBinding EditorFontSize}"
                                       Document="{Binding CurrentMacro.Expression, Converter={StaticResource TextToDocument}}"                                        
                                       TextChanged="editor_TextChanged"/>
                    </GroupBox>
                    <GroupBox Grid.Row="1"
                              Header="{x:Static t:Messages.Header_Result}">
                        <ScrollViewer>
                            <TextBox x:Name="resultView"
                                       FontFamily="{s:SettingsBinding EditorFontFamily}" 
                                       FontSize="{s:SettingsBinding EditorFontSize}"/>
                        </ScrollViewer>
                    </GroupBox>
                </Grid>
            </DockPanel>
        </HeaderedContentControl>
    </Grid>
</Window>

